<%@ page contentType="text/html;charset=UTF-8" %>

<!DOCTYPE html>
<html>
<head>
	<title>审核规则管理</title>
	<%@ include file="/common/meta.jsp" %>
    <%@ include file="/common/import.jsp" %>
	<script type="text/javascript">
		$(function(){
			$('#auditRuleList').datagrid({
				title:'审核规则列表',
				//iconCls:'icon-ok',
				url:'${ctx }/audit/auditRule/list.action',
				nowrap: false,
				striped: true,
				collapsible:false,				
				fitColumns: true,
				pagination:true,
				singleSelect:true,
				rownumbers:true,
				//remoteSort: false,
				idField:'ruleId',
				columns:[[
                    {field:'ruleId',title:'规则ID',width:100},
					{field:'tableName',title:'表名',width:120},
					{field:'ifStart',title:'是否起点',width:50,
						formatter:function(value,rec){
							var info = "";
							if(rec.ifStart == 'T'){
								info += "是";
							}else if(rec.ifStart == 'F'){
								info += "否";
							}
							return info;
						}
					},
					{field:'checkUser',title:'审核人',width:120},
					{field:'next',title:'通过',width:80},
					{field:'last',title:'不通过',width:80},
					{field:'num',title:'次数',width:60},
					{field:'auditType',title:'审核类型',width:80},
					{field:'opt',title:'操作',width:100,
						formatter:function(value,rec){
							var info = "";
							info += "<a href=\"javascript:void(0)\" onclick=\"toEdit('"
									+ rec.ruleId
									+ "')\" style=\"color: blue\" title='查看信息'>修改</a> ";

							info += " | <a href=\"javascript:void(0)\" onclick=\"del('"
									+ rec.ruleId
									+ "')\" style=\"color: red\" title='删除'>删除</a>";
							return info;
						}
					}
				]],
				toolbar:[{
					text:'增加',
					iconCls:'icon-add',
					handler:toSaveAuditRule
				}
				]	
			});		
		});
	
		//保存审核规则
		function toSaveAuditRule(){
			$('#auditRuleFrame').html('');
			//var url = '${ctx}/sendPage/member/auditRule/auditRule-save';
			var url = '${ctx}/sendPage/auditRule/auditRule-edit-actuser?flag=save';
			$('#auditRuleFrame').attr("src", url);
			$('#auditRuleDiv').window('open');
		}
		
		//编辑回显
		function toEdit(ruleId){
			if(ruleId){
				$('#auditRuleFrame').html('');
				//var url = '${ctx}/sendPage/member/auditRule/auditRule-edit?ruleId='+ruleId;
				var url = '${ctx}/sendPage/auditRule/auditRule-edit-actuser?flag=edit&ruleId='+ruleId;
				$('#auditRuleFrame').attr("src",url);
				$('#auditRuleDiv').window('open');	
			}
		}
		
		//删除
		function del(ruleId){
			if(ruleId){
				$.messager.confirm('确认','确定要删除吗?',function(flag){  
			        if(flag){  
			            $.ajax({
						  url: "${ctx}/audit/auditRule/delete.action?ruleId="+ruleId,
						  type: 'POST',
						  cache: false,
						  success: function(data){
						  	var oTxt = jQuery.parseJSON(data);
						    var mess = oTxt.msg;	
							var flag = oTxt.flag;
					        if(flag=="T"){
								$.messager.alert('提示',mess, 'info',function(){
									reload();
					        	});
							}else{
								$.messager.alert('提示',mess, 'error');
							}
						  }
						});
			        }  
			     });
			  }
		}
		
		//重新加载数据
		function reload() {
			$('#auditRuleList').datagrid('reload');
		}
		
		//关闭win
		 function closeWin(){
		 	$('#auditRuleDiv').window('close');	
		 }

	</script>
</head>
<body>

	<table id="auditRuleList"></table>
	
	<!-- 添加窗口 -->
	<div id="auditRuleDiv" class="easyui-window" title="审核规则" style="padding:5px;width: 550px;height:450px;"
    	iconCls="icon-edit" closed="true" maximizable="false" minimizable="false" collapsible="false">
   		<iframe frameborder="0"  id="auditRuleFrame" height="100%" width="100%" scrolling="No" frameborder="0" ></iframe>
    </div>
</body>
</html>